import { WebDriver, Builder } from 'selenium-webdriver'

// 使用typescript并设置单例模式
export class SingleInstance { // export导出
 
    private static instance: WebDriver;

    public static create_drive() {
        if (!this.instance) {
            this.instance = new Builder().forBrowser('chrome').build();
        }
        return this.instance;
    }

}

let driver1 = SingleInstance.create_drive()
let driver2 = SingleInstance.create_drive()
console.log(driver1 == driver2) // true